# 答题挑战赛。可以按q随时退出，而且有三次机会来作答，一共三个题目

question1, answer1 = '1+3', '4'
question2, answer2 = '1+7', '8'
question3, answer3 = '1+5', '6'

# 最大尝试次数
max_trice = 3
# 一共
total = 3
# 是否在游戏里
is_playing = True

for i in range(1, total + 1):
    if i == 1:
        question = question1
        answer = answer1


    elif i == 2:
        question = question2
        answer = answer2

    else:
        question= question3
        answer = answer3
    trice = 1
    while trice < max_trice + 1:
        answer5 = input(f'问题是{question}')
        if answer5 == answer:
            print("回答正确下一个")
            break
        elif answer5 == 'q':
            is_playing = False
            break

        elif answer5 == '':
            print("继续作答")
            continue
        else:
            print(f"回答错误继续作答还有{3 - trice}次")
            continue
    trice += 1
    if is_playing == False:
        print("非常抱歉挑战失败了")
        break

    if is_playing == True:
        print("成功了")
